<?php
	include('include/header.php');
	include("include/commands.php");

	$employee = getEmployee($_GET['id']);
	$schedule = getEmployeeSchedule($_GET['id']);
	$transactions = getTransactionsSorted('Date', $_GET['id']);
?>

	<div class="body">
	

		<h1> Employee Information: Detailed </h1>
		<hr style="length:200px;width:2px" />


	</br>
		<?php 
			
			if(sizeof($employee) > 0){
					generateEmployeeTable($employee);
			}
			else{
				echo "<p> No Employee(s) Found. </p>";
			}
		?>
		<h1>Employee Sales</h1>
		<?php
			if(sizeof($transactions) > 0){
				generateTransactionsTable($transactions);
			}
			else{
				echo "<p> No Transaction(s) Found. </p>";
			}
			?>
			<h1> Employee Schedule </h1>

			<?php
				if(sizeof($schedule) > 0){
					generateEmployeeScheduleTable($schedule);
				}
				else{
					echo "<p> No Schedule(s) Found. </p>";
				}
				
				function generateTransactionsTable($transactions) {
					echo "<table>";
					echo "<tr>";
					echo "<th>Id</th>";
					echo "<th>Model</th>";
					echo "<th>Color</th>";				
					echo "<th>Year</th>";
					echo "<th>Price($)</th>";
					echo "<th>Commission($)</th>";
					echo "<th>Total($)</th>";
					echo "<th>Employee Name</th>";
					
					echo "<th>Date</th>";
					echo "</tr>";
					generateTableBody($transactions);
					echo "</table>";
				}
				
				function generateEmployeeTable($employees) {

					echo "<table>";
					echo "<tr>";
					echo "<th>Employee Id</th>";
					echo "<th>First Name</th>";				
					echo "<th>Last Name</th>";
					echo "<th>Hire Date</th>";
					echo "<th>Phone Number</th>";
					echo "<th>Address</th>";
					echo "<th>Hourly Rate</th>";
					echo "<th>Employee Type</th>";
					echo "</tr>";
					generateEmployeeTableBody($employees);
					echo "</table>";
				}

				function generateEmployeeScheduleTable($schedule) {

					echo "<table>";
					echo "<tr>";
					echo "<th>Date</th>";
					echo "<th>Start Time</th>";				
					echo "<th>End Time</th>";
					echo "<th>Tips</th>";
					echo "</tr>";
					generateEmployeeTableBody($schedule);
					echo "</table>";
				}
				
		?>
	</div>


<?php 
	include('include/footer.php'); 
?>